package com.pkk.cloud.support.oauth2.center.runner.endpoint;

import com.pkk.components.rpc.response.CommonResponse;
import com.pkk.components.rpc.response.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 登出接口
 *
 * @author LIQIU
 * @date 2018-3-26
 **/
@FrameworkEndpoint
public class TokenRevokeEndpoint {

  @Autowired
  @Qualifier("consumerTokenServices")
  private ConsumerTokenServices tokenServices;

  /**
   * @Description: 退出登录
   * @Param: accessToken
   * @return: com.pkk.components.rpc.response.CommonResponse<java.lang.String>
   * @Author: peikunkun
   * @Date: 2020/3/18 0018 下午 3:45
   */
  @DeleteMapping("/oauth/token")
  public CommonResponse<String> deleteAccessToken(@RequestParam("access_token") String accessToken) {
    tokenServices.revokeToken(accessToken);
    return ResponseUtil.success();
  }

}
